<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script src="https://cdn.bootcdn.net/ajax/libs/angular.js/1.6.8/angular.min.js"></script>
  </head>
  <body>
    <div ng-app="myApp" ng-controller="myCtrl">
      <h1>{{indexName}}</h1>
      <!-- 自定义组件 -->
      <input type="text" ng-model="childName">
      <hello-world my-name="childName"></hello-world>
    </div>

    <script>
      var app = angular.module("myApp", []);
      app.controller("myCtrl", function ($scope) {
        $scope.indexName = "主页";
        $scope.childName = "我是传到组件中的信息";
      });
      app.component("helloWorld",{
        restrict: "E",
        template:`
            <div>
                <h3>自定义组件</h3>
                <input type="text" ng-model="$ctrl.myName"/>
            </div>
        `,
        bindings:{
            myName:"<"
        }
      })
    </script>
  </body>
</html>
